<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" style="padding: 15px 15px 0 15px;">
            <form class="layui-form" action="" lay-filter="component-form-group">
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-badge-dot layui-bg-orange"></i> 名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" lay-verify="required" autocomplete="off" placeholder=""
                               value="{$info.title}" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-block">
                        <input type="text" name="describe" autocomplete="off" placeholder=""
                               value="{$info.describe}" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-badge-dot layui-bg-orange"></i> 状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="status" value="1" title="激活" {eq name="info.status" value="1"
                               }checked="" {/eq} >
                        <input type="radio" name="status" value="0" title="停用" {eq name="info.status" value="0"
                               }checked="" {/eq} >
                    </div>
                </div>

                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <input type="hidden" name="id" value="{$info.id}">
                            <button class="layui-btn" lay-submit="" lay-filter="component-form-edit">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>


<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'laydate', 'upload'], function () {
        const $ = layui.$,
            admin = layui.admin,
            element = layui.element,
            layer = layui.layer,
            form = layui.form;

        form.render(null, 'component-form-group');

        /* 监听提交 */
        form.on('submit(component-form-edit)', function (data) {
            $.ajax({
                'url': 'edit',
                'data': data.field,
                'success': function (data) {
                    if (data.code === 0) {
                        layer.alert(data.msg,{
                            closeBtn: 0
                        },function (index) {
                            location.reload();
                            layer.close(index);
                        });
                    } else {
                        layer.alert(data.msg,{
                            skin: 'layui-layer-error' //样式类名
                            ,closeBtn: 0
                        });
                    }
                },
                'dataType': 'json',//返回的格式
                'type': 'post',//发送的格式
            });
            return false;
        });
    });
</script>